{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d34ee504",
   "metadata": {},
   "source": [
    "函数+模块=标准库"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "378ff6ec",
   "metadata": {},
   "source": [
    "# 时间模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c439505c",
   "metadata": {},
   "source": [
    "## 1.时间戳\n",
    "（记录的是指格林威治时间1970年01月01日00时00分00秒（北京时间1970年01月01日08时00分00秒）到现在等秒数（UNIX诞生元年）。）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "32ec97a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1667875784.9076512"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e929be3f",
   "metadata": {},
   "source": [
    "## 2.datetime模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "2bb4f0c4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime \n",
    "# 导入datetime模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5a009668",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 11, 8)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()\n",
    "# 使用datetime模块里面date.today函数，找出今天的日期"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aaefbdf5",
   "metadata": {},
   "source": [
    "## 2.1可以在date.today后面加一个属性来单独访问某日，某月，某年     如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "4e3f5b24",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "51b7189f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "693c0f5a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2022"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().year"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28430cf4",
   "metadata": {},
   "source": [
    "## 2.2 可以使用date.isoformat函数 后面加上今天的时间，日期可以 从datetime.date(2022, 11, 8) 转化成字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "4cc17be2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2022-11-08'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.isoformat(datetime.date.today())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9142564a",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 3."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
